<?php

namespace apiend\modules\home\models;

use Yii;
use common\helpers\Url;
use common\logics\PositionLogic;
use apiend\models\searchs\AssembleProductSearch;
use common\logics\ShopProductLogic;

/**
 * 首页推荐文章内容模型
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class RecommendSearch extends \common\base\Model {

    public $user_id;

    public function search() {
        $adverts = PositionLogic::current('shop.home.advert');
        /* @var $model \apiend\modules\shop\models\AssembleProductSearch */
        $model = new AssembleProductSearch();
        $model->tag = 'recommend';
        $recommend = $model->limitsSearch(6);
        $model->tag = 'hot';
        $hot = $model->limitsSearch(6);
        $model->tag = 'new';
        $new = $model->limitsSearch(6);
//        $spread = [
//            'id' => 10,
//            'name' => 'CW801儿童棒球服扣子立领',
//            'thumb' => Url::attach('attachments/goods/10.png'),
//            'slogan' => '给孩子探索大世界的小礼物',
//            'description' => '双面直立式支架，单面直立式支架，斜面底座，直面底座，功能居多。',
//            'price' => '399',
//        ];
        return [
            [
                'advert' => array_shift($adverts),
                'title' => '超值推荐',
                'spread' => null,
                'format' => 'ualf',
                'products' => $recommend,
            ],
            [
                'advert' => array_shift($adverts),
                'title' => '热销商品',
                'spread' => null,
                'format' => 'ualf',
                'products' => $hot,
            ],
            [
                'advert' => array_shift($adverts),
                'title' => '新品专区',
                'spread' => null,
                'format' => 'larf',
                'products' => $new,
            ]
        ];
    }

}
